package nk.presum;

import java.util.Scanner;

public class AB44 {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int q = scanner.nextInt();
        long [][] preSum = new long[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m ; j++) {
                int x = scanner.nextInt();
                preSum[i][j] = x + preSum[i-1][j] + preSum[i][j-1] - preSum[i-1][j-1];
            }
        }

        int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
        for (int i = 0; i < q; i++) {
            x1 = scanner.nextInt();
            y1 = scanner.nextInt();
            x2 = scanner.nextInt();
            y2 = scanner.nextInt();
            System.out.println(preSum[x2][y2] - preSum[x1 - 1][y2] - preSum[x2][y1 - 1]  + preSum[x1 - 1][y1 - 1]);
        }

    }












}
